import os 
import subprocess 
import re 
import hashlib
from multiprocessing import cpu_count
'''
if __name__ == "__main__":
     cpu_count()
'''
#! /usr/bin/env python  
#Filename:CPU1.py  
from collections import OrderedDict  
  
def CPUinfo():  
      
    CPUinfo=OrderedDict()  
    procinfo=OrderedDict()  
  
    nprocs = 0  
    with open('/proc/cpuinfo') as f:  
        for line in f:  
            if not line.strip():  
                #end of one processor  
                CPUinfo['proc%s' % nprocs]=procinfo  
                nprocs = nprocs+1  
                #Reset  
                procinfo=OrderedDict()  
            else:  
                if len(line.split(':')) == 2:  
                    procinfo[line.split(':')[0].strip()] = line.split(':')[1].strip()  
                else:  
                    procinfo[line.split(':')[0].strip()] = ''
    count = 0
    for processor in CPUinfo.keys():
        count = count + 1
        c_model = CPUinfo[processor]['model name']
    return count,c_model

'''  
if __name__ == '__main__':  
    CPUinfo = CPUinfo()
    count = 0
    for processor in CPUinfo.keys():
       count = count + 1
       print ('CPUinfo[{0}]={1}'.format(processor,CPUinfo[processor]['model name']))
    print count
    print ()
'''
